
import json
from pydantic import Field
from pydantic_settings import BaseSettings
from pathlib import Path


class Settings(BaseSettings):

    VERSION: str = '1.0'

    # 是否启用调试
    DEBUG: bool = False

    # 大模型配置
    LLM_URI : str = Field(default='', description='大模型URL')
    LLM_MODEL: str = Field(default='', description='大模型名称')
    LLM_API_KEY: str = '123456'

    LLM_HEADERS: str = Field(default=json.dumps({
         'Content-Type': 'application/json',
         'Authorization': 'Basic dXNlcm5hbWU6TWFpeXVlQDIwMjU=',
    }, ensure_ascii=False), description='某些大模型需要传入headers')
    LLM_MAX_INPUT: int = 2000

    # Embedding配置
    EMBEDDING_MODEL:str

    # Milvus 配置
    MILVUS_URI: str
    MILVUS_DBNAME: str

    # Reranker 配置
    RERANKER_MODEL: str

    # 召回文档个数
    TOP_K: int

    # 文本切片参数设置
    CHUNK_SIZE: int
    CHUNK_OVERLAP: int
    DOCUMENT_SIZE: int

    class Config:
        env_file = Path(__file__).parent.parent/ '.env'
        env_file_encoding = 'utf-8'

settings = Settings()
